package com.xbai.creation.builder;

import com.xbai.creation.builder.product.Car;
import com.xbai.creation.builder.product.Manual;

public class Demo {

    public static void main(String[] args) {
        Director director = new Director();

        // Director从客户端（应用程序代码）获取具体的构建器对象。这是因为应用程序更了解使用哪个生成器来获取特定产品。
        CarBuilder builder = new CarBuilder();
        director.constructSportsCar(builder);

        // 最终产品通常是从构建器对象中检索的，因为 Director不了解并且不依赖于具体的构建器和产品
        Car car = builder.getResult();
        System.out.println("Car built:\n" + car.getCarType());


        CarManualBuilder manualBuilder = new CarManualBuilder();
        director.constructSportsCar(manualBuilder);
        Manual carManual = manualBuilder.getResult();
        System.out.println("\nCar manual built:\n" + carManual.print());
    }

}